package tpenchere.service.ws;

import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tpenchere.dao.impl.EnchereDAO;
import tpenchere.model.Categorie;
import tpenchere.model.Enchere;
import tpenchere.model.Produit;
import tpenchere.model.User;

//tpenchere.service.ws.EnchereWSImpl ,targetNamespace = "http://intf.ws.back.qualoo.fr/", wsdlLocation = "META-INF/wsdl/Car.wsdl"
@Service
@WebService(endpointInterface = "tpenchere.service.ws.IEnchereWS", serviceName = "EnchereWebServiceService", portName = "EnchereWebServicePort")
public class EnchereWSImpl implements IEnchereWS {

	@Autowired
	EnchereDAO enchereDAOJpa;

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#getEnchereDAOJpa()
	 */
	public EnchereDAO getEnchereDAOJpa() {
		return enchereDAOJpa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#setEnchereDAOJpa(tpenchere.dao.impl.
	 * EnchereDAO)
	 */
	public void setEnchereDAOJpa(EnchereDAO enchereDAOJpa) {
		this.enchereDAOJpa = enchereDAOJpa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#connect(java.lang.String,
	 * java.lang.String)
	 */
	public User connect(String login, String password) {

		return enchereDAOJpa.connect(login, password);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#saveEnchere(tpenchere.model.Enchere)
	 */
	public Enchere saveEnchere(Enchere enchere) {
		Enchere e = enchereDAOJpa.createEnchere(enchere);
		return e;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * tpenchere.service.ws.IEnchereWS#createProduit(tpenchere.model.Produit)
	 */
	public Produit createProduit(Produit produit) {
		Produit p = enchereDAOJpa.getProduit(produit);
		if (p != null) {
			return p;
		}
		return enchereDAOJpa.createProduit(produit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#createUser(tpenchere.model.User)
	 */
	public User createUser(User user) {
		return enchereDAOJpa.createUser(user);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#getAllProduct()
	 */
	public List<Produit> getAllProduct() {
		return enchereDAOJpa.getAllProduct();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#getAllRootCategorie()
	 */
	public List<Categorie> getAllRootCategorie() {
		return enchereDAOJpa.getAllRootCategorie();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#getCurrentProduct()
	 */
	public List<Produit> getCurrentProduct() {
		return enchereDAOJpa.getCurrentProduct();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * tpenchere.service.ws.IEnchereWS#getProductBy(tpenchere.model.Categorie)
	 */
	public List<Produit> getProductBy(Categorie categorie) {
		return enchereDAOJpa.getProductBy(categorie);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#getProductSold()
	 */
	public List<Produit> getProductSold() {
		return enchereDAOJpa.getProductSold();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#loginUsed(java.lang.String)
	 */
	public boolean loginUsed(String login) {
		return enchereDAOJpa.loginUsed(login);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tpenchere.service.ws.IEnchereWS#getEnchere(tpenchere.model.Enchere)
	 */
	public Enchere getEnchere(Enchere enchere) {
		return enchereDAOJpa.getEnchere(enchere);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * tpenchere.service.ws.IEnchereWS#getEnchereFor(tpenchere.model.Produit)
	 */
	public List<Enchere> getEnchereFor(Produit produit) {
		return enchereDAOJpa.getEnchere(produit);
	}
}
